<template>
    <div class="detail">
        <van-card
            :num="detail.count"
            :price="detail.price"
            :desc="detail.detail"
            :title="detail.title"
            :thumb="detail.image"
        />
        <van-goods-action>
            <van-goods-action-icon icon="chat-o" text="客服" dot />
            <van-goods-action-icon icon="cart-o" text="购物车" badge="5" to="/cart" />
            <van-goods-action-icon icon="shop-o" text="店铺" badge="12" />
            <van-goods-action-button type="warning" text="加入购物车" @click="addToCartFun" />
            <van-goods-action-button type="danger" text="立即购买" />
        </van-goods-action>
    </div>
</template>

<script>
import { Toast } from 'vant'
export default {
    created() {
        this.getDetail()
    },
    data() {
        return {
            id: this.$route.params.id,
            detail: {}
        }
    },
    methods: {
        getDetail() {
            this.$api.getShopDetail(this.id).then(res => {
                if (res.success) {
                    this.detail = res.data
                }
            })
        },
        addToCartFun() {
            // 如果没哟登录 则提示去登录
            this.$api.addToCart({ shop_id: this.id, user_id: 1 }).then(res => {
                if (res.success) {
                    Toast.success(res.message)
                }
            })
        }
    }
}
</script>

<style>
</style>